package com.tanhua.model.vo;

import com.tanhua.model.db.Report;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Version 1.0
 * @Author aao
 * @Date 2022/2/22 8:17
 * @Description 报告返回vo
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReportVo {


    private String conclusion; //鉴定结果
    private String cover; //鉴定图片

    //维度:1.维度项key（外向，判断，抽象，理性）2.维度值value
    private List<Map<String,String>> dimensions;

    //- plan1先查redis有无与你相似的用户id集合 没有使用假数据
    //- plan2写一个根据问卷id获取(10条)相似用户信息的方法 排除自己
    private List<SimilarYouVo> similarYou; //与你相似


    /**
     * 在vo对象中，补充一个工具方法，封装转化过程
     */
    public static ReportVo init(Report report, List<SimilarYouVo> similarYou ) {
        //copy报告属性
        ReportVo vo = new ReportVo();
        BeanUtils.copyProperties(report,vo);
        //维度key与value
        Map<String, String> map1 = new HashMap<>();
        Map<String, String> map2 = new HashMap<>();
        Map<String, String> map3 = new HashMap<>();
        Map<String, String> map4 = new HashMap<>();

        map1.put("key", "外向分");
        map1.put("value", report.getOutgoing() + "%");

        map2.put("key", "判断分");
        map2.put("value", report.getJudge() + "%");

        map3.put("key", "理性分");
        map3.put("value", report.getAbstraction() + "%");

        map4.put("key", "抽象分");
        map4.put("value", report.getRationality() + "%");

        List<Map<String,String>> dimensionsList = new ArrayList<>();
        dimensionsList.add(map1);
        dimensionsList.add(map2);
        dimensionsList.add(map3);
        dimensionsList.add(map4);
        vo.setDimensions(dimensionsList);
        //与你相似列表
        vo.setSimilarYou(similarYou);
        return vo;
    }

}

